<template>
<view :class="[config.style]">
		<!--数据列表部分-->
		<view class="list-section uni-clearfix">
			<!-- top="xxx"下拉布局往下偏移,防止被悬浮菜单遮住 -->
			<mescroll-uni ref="mescrollRef" @init="mescrollInit" top="0" :down="downOption" @down="downCallback" @up="upCallback">
				<!-- 数据列表 -->
				<view class="list">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="type">
							{{item.type_str}}
						</view>
						
						<view class="price ">
							<view class="title">{{item.type_str}}金额</view>
							<view class="value">
								<text class="yuan">￥</text>
								<text>{{item.price}}</text>
							</view>
						</view>
						<view class="others">
							<view class="other desc">{{item.description}}</view>
							<view class="other flow-no">流水号：{{item.flow_no}}</view>
							<view class="other time">时间：{{item.create_time_str}}</view>
						</view>
					</view>
				</view>
			</mescroll-uni>
		</view>
	</view>
</template>

<script>
	import { mapState,mapMutations } from 'vuex'
	export default {
		data() {
			return {

				page: 1, //当前页码
				list: [], // 订单列表
				downOption: {
					auto: false //是否在初始化后,自动执行downCallback; 默认true
				},
				upOption:{
					// page: {
					// 	size: 10 // 每页数据的数量
					// },
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty:{
						tip: '~ 搜索无数据 ~', // 提示
						btnText: '去看看'
					}
				},
			}
		},
		created() {

		},
		computed: {
			...mapState(['config'])
		},
		methods: {

			//上拉加载的回调
			upCallback: function() {
				let that = this
				let data = {}
					data.action = 'capitalflow'
					data.page = this.page
				//获取数据
				let url = '';
					//#ifdef MP-WEIXIN
					url = 'entry/wxapp/distribution'
					//#endif
					//#ifdef H5
					url = 'entry/site/distribution'
					//#endif
				this.util.request({
					url : url,
					data : data,
					success: function (res) {
						if (res.data.code == 200) {
							let list = res.data.data.data
							that.list = that.list.concat(list);
							//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
							that.mescroll.endSuccess(list.length);
							that.page = that.page + 1
						}
					}
				})
			},
			//下拉刷新
			downCallback: function() {
				let that = this
				this.page = 1
				let data = {}
					data.page = this.page
					data.action = 'capitalflow'
				//获取数据
				let url = '';
					//#ifdef MP-WEIXIN
					url = 'entry/wxapp/distribution'
					//#endif
					//#ifdef H5
					url = 'entry/site/distribution'
					//#endif
				this.util.request({
					url : url,
					data : data,
					success: function (res) {
						if (res.data.code == 200) {
							that.list = []
							that.list = res.data.data.data
							//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
							that.mescroll.endSuccess(that.list.length);
							that.page = 2
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #f8f8f8;
		min-height: 100%;
		height: auto;
	}
	
	.list {
		
		.item {
			padding: 20rpx;
			background-color: #fff;
			margin: 20rpx;
			border-radius: 10rpx;
			box-shadow: 0 0 10rpx rgba(0,0,0,.02);
			.type {
				font-size: 32rpx;
				font-weight: 700;
			}
			.price {
				margin: 40rpx 0 30rpx 0;
				text-align: center;
				.title {
					font-size: 24rpx;
					line-height: 44rpx;
					color: #999
				}
				.value {
					font-size: 42rpx;
					line-height: 42rpx;
					color: #000;
					font-weight: 700;
					.yuan {
						font-size: 28rpx;
					}
				}
			}
			.desc {
				color: #999;
				font-size: 24rpx;
			}
			.others {
				color: #999;
				font-size: 28rpx;
				line-height: 32rpx;
				
				.other {
					padding: 10rpx 0;
					border-top: 2rpx #f8f8f8 solid;
				}
			}
		}
	}
</style>
